<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pr="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ezcomp="http://java.sun.com/jsf/composite/ezcomp">

    <ui:composition template="/WEB-INF/facelets/template.xhtml">

        <ui:param name="title" value="View orders"/>

        <ui:define name="content">
            <h1>This is vieworder.xhtml</h1>

            <pr:growl id="exceptions" showDetail="true"/>
            <pr:panel id="paymentPanel" toggleable="true" header="Payment status"
                      collapsed="#{orderBackingBean.isPaid()}">
                <h:outputText rendered="#{orderBackingBean.isPaid()}" value="Invoice paid in full"/>

                <h:form>
                    <h:outputText value="Invoice id: #{orderBackingBean.trackingNumber}"/><br/>
                    <h:outputText value="Total amount: #{orderBackingBean.totalAmount}"/><br/>
                    <h:outputText value="Paid amount: #{orderBackingBean.paidAmount}"/><br/>

                    <h:outputText value="Outstanding debt: #{orderBackingBean.outstanding}"/><br/>
                </h:form>

                <h:form>
                    <h:outputLabel for="paymentAmount" value="Payment to make"/>
                    <h:inputText id="paymentAmount" maxlength="5" value="#{orderBackingBean.paymentAmount}">
                        <f:validateLongRange minimum="0"/>
                    </h:inputText>
                    <pr:commandButton value="Pay" update="exceptions paymentPanel" type="Submit" action="#{orderBackingBean.doPayment()}"/>
                </h:form>
            </pr:panel>
            
            <ezcomp:OrderDisplay orderBean="#{orderBackingBean}"/>

        </ui:define>
    </ui:composition>
</html>

